const express = require('express');
const router = express.Router();
const { adminAuth } = require('@middlewares/auth');
const adminController = require('@controllers/admin/admin');
const orderController = require('@controllers/admin/order');
const bannerController = require('@controllers/admin/banner');

// 管理员登录
router.post('/login', adminController.login);

// 需要认证的路由
router.use(adminAuth);

// 管理员认证相关
router.get('/auth/current', adminController.info);
router.put('/auth/current', adminController.updateInfo);
router.post('/auth/logout', adminController.logout);
router.put('/auth/password', adminController.updatePassword);
router.put('/auth/avatar', adminController.updateAvatar);

// 商品分类管理
router.use('/categories', require('./admin/category.route'));

// 商品管理
router.use('/products', require('./admin/product.route'));

// 订单管理
router.get('/orders', orderController.list);
router.get('/orders/:id', orderController.detail);
router.put('/orders/:id/deliver', orderController.deliver);

// 轮播图管理
router.get('/banners', bannerController.list);
router.post('/banners', bannerController.create);
router.put('/banners/:id', bannerController.update);
router.delete('/banners/:id', bannerController.delete);
router.put('/banners/:id/status', bannerController.updateStatus);

module.exports = router; 